<template>
  <div class='cart_box'>
    <van-card
      num="2"
      :price="item.info.price"
      desc="描述信息"
      :title="item.info.title"
      :thumb="item.info.pic"
      v-for='item in list'
      :key='item.id'
    >
      <template #tag>
              <van-checkbox v-model="item.checked"></van-checkbox>
      </template>
      <template #num>
          <van-stepper v-model="item.count" />
      </template>
      <template #footer>
        <van-button size="mini">按钮</van-button>
        <van-button size="mini">按钮</van-button>
      </template>
    </van-card>

    <van-submit-bar :price="total" button-text="提交订单" @submit="onSubmit" />
  </div>
</template>
<script>
// @ is an alias to /src
export default {
  name: "XXX",
  data() {
    return {};
  },
  created() {
    console.log(this.$store.state);
  },
  methods: {
      onSubmit(){
          console.log(arguments)
      }
  },
  computed: {
      list(){
          return this.$store.state.cartList
      },
      total(){
          return this.list.reduce((prev,cur)=>{
              return cur.checked ? prev + cur.info.price * cur.count : prev;
          },0) * 100
      }
  }
};
</script>
<style lang="less">
    .cart_box{
        text-align: left;
        padding-bottom: 50px;
    }
</style>